﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Container : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack) {
            string[] name = { "张三", "李四" };
            string[] number = { "2017001","2017002"};
            for (int i=0;i<name.Length;i++) {
                TableRow row = new TableRow();
                TableCell cellName = new TableCell();
                TableCell cellNumber = new TableCell();
                cellName.Text = name[i];
                cellNumber.Text = number[i];

                TextBox tb = new TextBox();
                TableCell cellGrade = new TableCell();
                cellGrade.Controls.Add(tb);
                row.Cells.Add(cellName);
                row.Cells.Add(cellNumber);
                row.Cells.Add(cellGrade);
                Table1.Rows.Add(row);
            }
            TableRow rowFoot = new TableRow();
            rowFoot.TableSection = TableRowSection.TableFooter;
            TableCell cellStar = new TableCell();
            cellStar.ColumnSpan = 2;
            cellStar.Text = "统计：";
            cellStar.HorizontalAlign = HorizontalAlign.Right;
            TableCell cellTotal = new TableCell();
            cellTotal.Text = "共计" + name.Count() + "条信息";
            rowFoot.Cells.Add(cellStar);
            rowFoot.Cells.Add(cellTotal);
            Table1.Rows.Add(rowFoot);

            Panel1.Visible = true;
            Panel2.Visible = false;
        }
        Button btn = new Button();
        btn.ID = "BtnSubmit";
        btn.Text = "提交";
        btn.Click += BtnSubmit_Click;
        PlaceHolder1.Controls.Add(btn);
        TextBox _tb = new TextBox();
        _tb.ID = "txtInput";
        PlaceHolder1.Controls.Add(_tb);
    }

    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        Label3.Text = "动态添加按钮事件响应";
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = true;
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        Panel1.Visible = false;
        Panel2.Visible = false;
        Label3.Text = Literal1.Text + Literal2.Text;
    }

    protected void BtnTest_Click(object sender, EventArgs e)
    {
        TextBox _tb = PlaceHolder1.FindControl("txtInput") as TextBox;
        Label3.Text = _tb.Text;
    }

    protected void LbtnView1_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View1);
    }

    protected void LbtnView2_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View2);
    }
}